<template>
  <el-card class="me-area" :body-style="{ padding: '16px' }">
    <div class="me-article-header">
      <a class="me-article-title" @click="view(id)">{{title}}</a>
      <el-button v-if="weight == 2" class="me-article-icon-top" type="text">置顶</el-button>
      <el-button v-if="weight > 0" class="me-article-icon-new" type="text">NEW</el-button>
      <span class="me-pull-right me-article-count">
        <i class="el-icon-chat-dot-round"></i>&nbsp;{{commentCounts}}
      </span>
      <span class="me-pull-right me-article-count">
        <i class="el-icon-view"></i>&nbsp;{{viewCounts}}
      </span>
    </div>

    <div class="me-artile-description">
      {{summary}}
    </div>
    <div class="me-article-footer">
      <span class="me-article-author">
        <i class="me-icon-author"></i>&nbsp;{{author}}
      </span>

      <el-button plain class="tagButton" @click="tagDetail(t)" v-for="t in tags" :key="t.tagName" size="mini"
        type="success">{{t.tagName}}
      </el-button>

      <span class="me-pull-right me-article-count">
        <i class="el-icon-time"></i>&nbsp;{{createDate | format}}
      </span>

    </div>
  </el-card>
</template>

<script>
  import {
    formatTime
  } from "../../utils/time";

  export default {
    name: 'ArticleItem',
    props: {
      id: String,
      weight: Number,
      title: String,
      commentCounts: Number,
      viewCounts: Number,
      summary: String,
      author: String,
      tags: Array,
      createDate: String
    },
    data() {
      return {}
    },
    methods: {
      view(id) {
        this.$router.push({
          path: `/view/${id}`
        })
      },
      tagDetail(t) {
        this.$router.push({
          path: `/tag/${t.id}`
        })
      }
    }
  }
</script>

<style scoped>
  .me-article-header {
    /*padding: 10px 18px;*/
    padding-bottom: 10px;
  }

  .me-article-title {
    font-weight: 600;
  }

  .me-article-icon-top {
    color: white;
    border: 1px;
    background-color: seagreen;
    padding: 3px 8px;
  }

  .me-article-icon-new {
    color: white;
    border: 1px;
    background-color: indianred;
    padding: 3px 8px;
  }

  .me-article-count {
    color: #a6a6a6;
    padding-left: 14px;
    font-size: 13px;
  }

  .me-pull-right {
    float: right;
  }

  .me-artile-description {
    font-size: 13px;
    line-height: 24px;
    margin-bottom: 10px;
  }

  .me-article-author {
    color: #a6a6a6;
    padding-right: 18px;
    font-size: 13px;
  }

  .el-button {
    margin-left: 6px;
  }

  .tagButton {
    padding: 5px;
  }
</style>
